package Factory.SimpleFactory;

/**
 * 简单工厂模式
 * 1.Factory：工厂类
 * 2.Product:抽象类产品
 * 3.具体产品
 */
public class OperationFactory {

    public static Operation createOperation(String operate) {
        Operation oper = null;

        switch (operate) {
            case "add":
                oper = new OperationAdd();
                break;
            case "sub":
                oper = new OperationSub();
                break;
            case "mul":
                oper = new OperationMul();
                break;
            case "div":
                oper = new OperationDiv();
                break;
            default:
                return null;

        }
        return oper;
    }
}
